/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package tests.domainModel;

import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import domainModel.Member;
import domainModel.MemberInt;
import domainModel.Post;
import domainModel.PostInt;
import domainModel.Topic;
import static org.junit.Assert.*;

/**
 *
 * @author iziko
 */
public class TopicTest {

    Topic instance;
    Member mem;
    
    public TopicTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
        mem = new Member(1,"iziko","iz@mail","izik","orgad");
        instance = new Topic("cars",mem);
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of addPost method, of class Topic.
     */
    @Test
    public void testAddPost() {
        System.out.println("addPost");
        PostInt newPost = new Post(mem,"honda","is graet");
        instance.addPost(newPost);
        assertTrue(instance.getPosts().contains(newPost));
    }

    /**
     * Test of getCreationTime method, of class Topic.
     */
    @Test
    public void testGetCreationTime() {
        System.out.println("getCreationTime");
        Date expResult = new Date();
        Date result = instance.getCreationTime();
        assertEquals(expResult, result);
    }

    /**
     * Test of getId method, of class Topic.
     */
    @Test
    public void testGetId() {
        System.out.println("getId");
        int expResult = 2;
        int result = instance.getId();
        assertEquals(expResult, result);
    }

    /**
     * Test of getTitle method, of class Topic.
     */
    @Test
    public void testGetTitle() {
        System.out.println("getTitle");
        String expResult = "cars";
        String result = instance.getTitle();
        assertEquals(expResult, result);
    }

    /**
     * Test of removePost method, of class Topic.
     */
    @Test
    public void testRemovePost() {
        System.out.println("removePost");
        int postId = 0;
        instance.removePost(postId);
        assertFalse(instance.getPosts().size() >0);
    }

    /**
     * Test of setTitle method, of class Topic.
     */
    @Test
    public void testSetTitle() {
        System.out.println("setTitle");
        String title = "animalse";
        instance.setTitle(title);
        assertEquals(title,instance.getTitle());
    }

    /**
     * Test of getCreator method, of class Topic.
     */
    @Test
    public void testGetCreator() {
        System.out.println("getCreator");
        MemberInt expResult = mem;
        MemberInt result = instance.getCreator();
        assertEquals(expResult, result);
    }

    /**
     * Test of setCreator method, of class Topic.
     */
    @Test
    public void testSetCreator() {
        System.out.println("setCreator");
        MemberInt creator = new Member(2,"iziko2","iz@mail","izik","orgad");;
        instance.setCreator(creator);
        assertEquals(creator,instance.getCreator());
    }


}